package com.scf.fruit.shiro.impl;

import com.scf.fruit.shiro.PermissionDto;
import com.scf.fruit.shiro.PermissionRelationDto;
import com.scf.fruit.shiro.PermissionRelationService;
import com.scf.fruit.shiro.dao.PermissionRelationMapper;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import tk.mybatis.mapper.entity.Example;

import javax.annotation.Resource;
import java.util.Collection;
import java.util.List;

/**
 * @author : 孙超飞
 * @title :
 * @description :
 * @date : 2018-04-23 10:42
 */
@Service
public class PermissionRelationServiceImpl implements PermissionRelationService {
    @Resource
    private PermissionRelationMapper permissionRelationMapper;
    @Override
    public List<PermissionRelationDto> queryList(PermissionRelationDto dto) {
        return permissionRelationMapper.select(dto);
    }

    @Override
    public List<PermissionRelationDto> queryRelationByList(Collection<Long> collection) {
        if(CollectionUtils.isEmpty(collection)){
            return null;
        }else {
            Example example=new Example(PermissionRelationDto.class);
            Example.Criteria criteria=example.createCriteria();
            criteria.andIn("roleId",collection);
            return permissionRelationMapper.selectByExample(example);
        }

    }
}
